package com.odata.springboot.starter.odata.odata.sql.process;

import com.odata.springboot.starter.odata.odata.sql.sqlBuild.OdataSqlInformation;
import org.apache.olingo.server.api.OData;
import org.apache.olingo.server.api.uri.UriInfo;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenYX
 * @date 2021/6/28 11:07
 * @description
 */
@Component
public class SqlProcessChain extends SqlProcess {

    private List<SqlProcess> sqlProcessList = new ArrayList<>();

    @Override
    public void process(OdataSqlInformation.SqlInformationBuild sqlBuild, UriInfo uriInfo, Class<?> aClass, OData oData) {
        if (!CollectionUtils.isEmpty(sqlProcessList)){
            for (SqlProcess sqlProcess : sqlProcessList) {
                sqlProcess.process(sqlBuild,uriInfo,aClass,oData);
            }
        }
    }

    public void addSqlProcess(SqlProcess sqlProcess){
        this.sqlProcessList.add(sqlProcess);
    }

}
